﻿using System.Text;

namespace System.Security.Cryptography
{

    public static class AlgorithmExtensions
    {
        private static readonly byte[] cryptoKey = Encoding.UTF8.GetBytes("SN5J>ALI_I7Cryp4toTran2sform>>9S03BJ01-W09SGXBA<K1MN1XBZLAPEDF:TY8CBN*VKA6ZW");

        public static byte[] ComputeHash(this HashAlgorithmName hashAlgorithm, string input, Encoding? encoding = null)
        {
            encoding ??= Encoding.UTF8;
            byte[] bytes = encoding.GetBytes(input);
            HashAlgorithm algorithm = HashAlgorithm.Create(hashAlgorithm.Name!)!;
            byte[] output = algorithm.ComputeHash(bytes);
            return output;
        }
    }
}